package com.vinay.shape;

public class Triangle extends Shape {

	private double shapeSide1;
	private double shapeSide2;
	private double shapeSide3;

	public double getShapeSide1() {
		return shapeSide1;
	}

	public double getShapeSide2() {
		return shapeSide2;
	}

	public double getShapeSide3() {
		return shapeSide3;
	}

	public Triangle(double shapeSide1, double shapeSide2, double shapeSide3) {
		super(null, shapeSide1, shapeSide2, shapeSide3);
		this.shapeSide1 = shapeSide1;
		this.shapeSide2 = shapeSide2;
		this.shapeSide3 = shapeSide3;
		if (!isValid())
			System.err.println("Triangle not valid");
	}

	public double getPerimeter() {
		return shapeSide1 + shapeSide2 + shapeSide3;
	}

	public double getArea() {
		double p = (shapeSide1 + shapeSide2 + shapeSide3) / 2;
		return Math.sqrt(p * (p - shapeSide1) * (p - shapeSide2) * (p - shapeSide3));
	}

	public boolean isValid() {
		if (shapeSide1 + shapeSide2 > shapeSide3 && shapeSide1 + shapeSide3 > shapeSide2 && shapeSide2 + shapeSide3 > shapeSide1)
			return true;
		else
			return false;
	}
}